package execute

import (
	"net"
	"strings"
)

func checkNetError(err error) bool {
	if strings.Contains(err.Error(), "Timeout") ||
		strings.Contains(err.Error(), "socks") ||
		strings.Contains(err.Error(), "net error") ||
		strings.Contains(err.Error(), "EOF") {
		return true
	} else {
		return false
	}
}

/* 检测是否是设置的超时时间到了()*/
func checkDeadlineExceededError(err error) bool {
	if strings.Contains(err.Error(), "context deadline exceeded (Client.Timeout exceeded while awaiting headers)") {
		return true
	} else {
		return false
	}
}

func checkIPError(err error) bool {
	if strings.Contains(err.Error(), "It looks like you were misusing this feature by going too fast") {
		return true
	} else {
		return false
	}
}

func isNetError(err error) bool {

	if netErr, ok := err.(*net.OpError); ok && netErr.Timeout() {
		return true
	}

	return false
}
